{% extends 'base.html' %}
{% load staticfiles %}

{% block title %}
    {{ page_title }}
{% endblock %}

{% block nav_home_active %}
    active
{% endblock %}

{% block content %}
    <div class="containter">
        <div class="row">
            <div class="col-xs-4 col-xs-offset-4">
                {% if user.is_authenticated %}
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">{{ form_title }}</h3>
                        </div>
                        <div class="panel-body">
                            <form action="" method="POST">
                                {% csrf_token %}
                                {#                            {{ login_form }}#}
                                {% for field in form %}
                                    {% if not field.is_hidden %}
                                        <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                                    {% endif %}
                                    {{ field }}
                                    <p class="text-danger">{{ field.errors.as_text }}</p>
                                {% endfor %}
                                <span id="tip" class="text-danger">{{ form.non_field_errors }}</span>
                                <div class="clearfix"></div>
                                <div class="pull-left">
                                    {% block other_buttons %}{% endblock %}
                                </div>
                                <div class="pull-right">
                                    <input type="submit" value="{{ submit_text }}" class="btn btn-primary ">
                                    <span class="btn btn-default "
                                          onclick="window.location.href='{{ return_back_url }}'">
                                    返回
                                </span>
                                </div>

                            </form>


                        </div>
                    </div>
                {% else %}
                    <span>未登录，跳转到首页</span>
                    <script type="text/javascript">
                        alert('未登录，返回首页');
                        window.location.href = '/';
                    </script>


                {% endif %}
            </div>
        </div>
    </div>


{% endblock %}